import react,{useState,useEffect} from "react"

export default function usePosition(){
    const[position,setPosition]=useState({x:0,y:0})
    useEffect(()=>{
        function getPosition(event){
            setPosition({x:event.clientX,y:event.clientY})
        }

        document.addEventListener("click",getPosition)
        return ()=>{
            document.removeEventListener("click",getPosition)
        }
    })

    return {
        position,setPosition
    }
}